<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0">
		

  
    <p:growl id="messages_growl" globalOnly="true" showDetail="true"/>
    
    <p:dataTable id="dataTable" var="cat" value="#{categoriaBean.categorias}" sortMode="multiple" rows="25" paginator="true">  
        <f:facet name="header">  
            Categorias 
        </f:facet>  
  
        <p:column sortBy="nome" headerText="Nome">  
            <h:outputText value="#{cat.nome}" />  
        </p:column>  
  
        <p:column sortBy="descricao" headerText="Descricao">  
            <h:outputText value="#{cat.descricao}" />  
        </p:column>  
        
        <!-- EDIT BUTTON -->
			<p:column id="btnEdit" style="width:25px" headerText="Editar">
				<p:commandButton title="Edit"  icon="ui-icon-pencil"
					ajax="true" update=":formCategoria" oncomplete="categoriaDialog.show();"
					actionListener="#{categoriaBean.btnEdit(cat)}" />
		    	</p:column>
        
        <!-- DELETE BUTTON -->
			<p:column id="btnDelete" style="width:35px" headerText="Deletar">
				<p:commandButton title="Delete" icon="ui-icon-close" ajax="true" update=":formManageCategoria"
					oncomplete="confirmation.show();" actionListener="#{categoriaBean.prepareToDelete(cat)}" />
			</p:column>
   
    </p:dataTable>  
    
    <!-- Delete Message -->
		<p:dialog header="Delete Categoria"
			widgetVar="confirmation">
			<!-- Confirmation question -->
			<h:outputText value="Deletar Categoria?" />

			<!-- Yes button -->
			<p:commandButton value="YES" title="YES" style="margin-top:15px;"
				update="messages_growl, :formManageCategoria"
				onstart="confirmation.hide()"
				actionListener="#{categoriaBean.btnDelete()}" />

			<!-- No button -->
			<p:commandButton value="NO" title="NO"
				onclick="confirmation.hide()" type="button" />
		</p:dialog>
  
	

</ui:composition>